package me.sunpeng.design.singleton.type2;

/**
 * @author sp
 */
public class SingletonTest02 {

}

//饿汉式 (静态变量)
class Singleton {
    //1. 构造器私有化
    private Singleton() {

    }

    private static Singleton intance;

    //在静态代码块中，创建单例对象
    static {
        intance = new Singleton();
    }

    public static  Singleton  getInstance(){
        return intance;
    }
}
